<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/> 
    <title>微信支付</title>
    <script type="text/javascript">
	//调用微信JS api 支付
	function jsApiCall()
	{
		WeixinJSBridge.invoke(
			'getBrandWCPayRequest',
			<?php echo $jsApiParameters; ?>,
			function(res){
			 //   alert(res.err_code+res.err_desc+res.err_msg);
				// WeixinJSBridge.log(res.err_msg);
				alert("您已取消");
			}
			
		);
	}

	function callpay()
	{
		if (typeof("WeixinJSBridge") == "undefined"){
		    if( document.addEventListener ){
		        document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
		    }else if (document.attachEvent){
		        document.attachEvent('WeixinJSBridgeReady', jsApiCall); 
		        document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
		    }
		}else{
		    jsApiCall();
		}
	}
	</script>
	<script type="text/javascript">
	//获取共享地址
	function editAddress()
	{
		WeixinJSBridge.invoke(
			'editAddress',
			<?php echo $editAddress; ?>,
			function(res){
				var value1 = res.proviceFirstStageName;
				var value2 = res.addressCitySecondStageName;
				var value3 = res.addressCountiesThirdStageName;
				var value4 = res.addressDetailInfo;
				var tel = res.telNumber;
			}
		);
	}
	
	window.onload = function(){
		if (typeof WeixinJSBridge == "undefined"){
		    if( document.addEventListener ){
                document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
		        document.addEventListener('WeixinJSBridgeReady', editAddress, false);
		    }else if (document.attachEvent){
		        document.attachEvent('WeixinJSBridgeReady', editAddress); 
		        document.attachEvent('onWeixinJSBridgeReady', editAddress);
		    }
		}else{
			editAddress();
		}
	};
	</script>
</head>
<body>
    <br/>
    <font color="#999999" style="text-align:center;"><p>您正在780g网站上购买商品：{$pay_order.game}{$pay_order.server}{$pay_order.title}</p><b>     &nbsp; &nbsp; 该笔订单支付金额为<span style="color:#f00;font-size:50px">{$money}</span>元</b></font><br/><br/>
	<div align="center">
		<button style="width:210px; height:50px; border-radius: 25px;background-color:#FE6714; border:0px #ff6600 solid; cursor: pointer;  color:white;  font-size:16px;" type="button" onclick="callpay()" id="callpay" >立即支付</button>
	</div>
</body>
<script src="https://cdn.staticfile.org/jquery/2.1.4/jquery.min.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
    
    $(document).ready(function(){
        // $("#callpay").click();
        var ref = setInterval(function(){
            var trade = "{$pay_order.order_sn}";
            var v_or = "{$v_order}";
            $.get("/BfcTyWlLqd.php/vxpay/pay/check_outtrade",{trade:trade,v_type:v_or},function(data){
                var obj = jQuery.parseJSON(data);
                if(obj.code == 1){
                     clearInterval(ref);
                     WeixinJSBridge.call("closeWindow");
                }
            });
        }, 1000)
        // setTimeout(function(){
        //     WeixinJSBridge.call("closeWindow");
        // },3000);
    })
</script>
</html>